package ogs.lib.mina.core.filterchain
{
	public class NextFilterImpl implements NextFilter
	{
		private var filterChain:DefaultIoFilterChain;
		
		private var node:IoFilterChainNodeImpl;
		
		public function NextFilterImpl(filterChain:DefaultIoFilterChain, node:IoFilterChainNodeImpl)
		{
			this.filterChain = filterChain;
			this.node = node;
		}
		
		public function sessionOpened():void
		{
			var nextNode:IoFilterChainNode = node.nextNode;
			filterChain.callNextSessionOpened(nextNode);
		}
		
		public function sessionClosed():void
		{
			var nextNode:IoFilterChainNode = node.nextNode;
			filterChain.callNextSessionClosed(nextNode);
		}
		
		public function exceptionCaught(cause:Error):void
		{
			var nextNode:IoFilterChainNode = node.nextNode;
			filterChain.callNextExceptionCaught(nextNode, cause);
		}
		
		public function messageReceived(message:Object):void
		{
			var nextNode:IoFilterChainNode = node.nextNode;
			filterChain.callNextMessageReceived(nextNode, message);
		}
		
		public function filterWrite(message:Object):void
		{
			var nextNode:IoFilterChainNode = node.prevNode;
			filterChain.callPreviousFilterWrite(nextNode, message);
		}
		
		public function filterClose():void
		{
			var nextNode:IoFilterChainNode = node.prevNode;
			filterChain.callPreviousFilterClose(nextNode);
		}
	}
}